package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.ProductionOrder;
import com.qidianit.mes.pojo.pro.Workflow;
import com.qidianit.mes.pro.service.ProductionOrderService;
import com.qidianit.mes.pro.service.WorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:16
 */
@RestController
@RequestMapping("/productionOrder")
@CrossOrigin
public class ProductionOrderController {
    @Autowired
    private ProductionOrderService productionOrderService;
    @GetMapping("/list")
    public Result<PageInfo<ProductionOrder>> selectList
            (ProductionOrder productionOrder,  @RequestParam(defaultValue = "1") int pageNum , @RequestParam(defaultValue = "10") int pageSize){
        return productionOrderService.selectList(productionOrder,pageNum,pageSize);
    }
    @GetMapping("/id/{id}")
    public Result<ProductionOrder> selectById(@PathVariable Long id){
        return productionOrderService.selectById(id);
    }

    @GetMapping("/productionOrderCode/{productionOrderCode}")
    public Result<ProductionOrder> selectByProductionOrderCode(@PathVariable String productionOrderCode){
        return productionOrderService.selectByProductionOrderCode(productionOrderCode);
    }
    @PostMapping("/add")
    public Result insertProductionOrder(@RequestBody ProductionOrder productionOrder) {
        return productionOrderService.insertProductionOrder(productionOrder);
    }
    @PutMapping("/update")
    public Result updateById(@RequestBody ProductionOrder productionOrder) {
        return productionOrderService.updateById(productionOrder);
    }
    @DeleteMapping("/delete/{id}")
    public Result deleteById (@PathVariable Long id) {
        return productionOrderService.deleteById(id);
    }


    @GetMapping("/status")
    public Result<PageInfo<ProductionOrder>> selectListStatus
            (ProductionOrder productionOrder,  @RequestParam(defaultValue = "1") int pageNum , @RequestParam(defaultValue = "10") int pageSize){
        return productionOrderService.selectListStatus(productionOrder,pageNum,pageSize);
    }

    @GetMapping("/workflows/{id}")
    public Result<ArrayList<Workflow>> selectWorkflowById(@PathVariable Long id) {
        return productionOrderService.selectWorkflowById(id);
    }
    @PutMapping("/update/{id}")
    public Result updateStatusById(@PathVariable Long id) {
        return productionOrderService.updateStatusById(id);
    }
    @PutMapping("/update2/{id}")
    public Result updateStatusById2(@PathVariable Long id) {
        return productionOrderService.updateStatusById2(id);
    }
    @PutMapping("/update3/{id}")
    public Result updateStatusById3(@PathVariable Long id) {
        return productionOrderService.updateStatusById3(id);
    }


}
